"use strict";
/**
 * @ Author: Yoann Meclot. MSay2
 * @ Created on: 2021-06-11 11:56:05
 * @ Modified on: 2021-06-16 13:32:05
 *
 * @version 1.0
 */
/**
 * Copyright (c) 2020-2021 MSay2 (Yoann Meclot) - @msay2/tspoet
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, privateMap, value) {
    if (!privateMap.has(receiver)) {
        throw new TypeError("attempted to set private field on non-instance");
    }
    privateMap.set(receiver, value);
    return value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, privateMap) {
    if (!privateMap.has(receiver)) {
        throw new TypeError("attempted to get private field on non-instance");
    }
    return privateMap.get(receiver);
};
var _mPath, _mName, _mListeners, _mHandlerType, _mHandlerImport, _mHandlerListener, _mCasts, _name, _path, _listener;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ObjectName = void 0;
const ArrayList_js_1 = require("../util/list/ArrayList.js");
const Arrays_js_1 = require("../util/list/Arrays.js");
const Objects_js_1 = require("../util/Objects.js");
/**
 * The ObjectName object allows you to write your own objects or type and/or casts it's with other object(s).
 *
 * Use static fields for write primitive type.
 *
 * @class `ObjectName`
 * @version 1.0
 */
class ObjectName {
    constructor(path, name, ...listener) {
        _mPath.set(this, void 0);
        _mName.set(this, void 0);
        _mListeners.set(this, void 0);
        _mHandlerType.set(this, void 0);
        _mHandlerImport.set(this, void 0);
        _mHandlerListener.set(this, void 0);
        _mCasts.set(this, void 0);
        __classPrivateFieldSet(this, _mPath, path);
        __classPrivateFieldSet(this, _mName, name);
        __classPrivateFieldSet(this, _mListeners, listener);
        __classPrivateFieldSet(this, _mCasts, new ArrayList_js_1.ArrayList());
    }
    /**
     * Build new object name.
     *
     * @param path The path of file.
     * @param name The name object to be exported.
     * @param listeners For nested classes.
     * @type {ObjectName}
     * @since 1.0
     */
    static get(path, name, ...listeners) {
        return new ObjectName(path, name, ...listeners);
    }
    /**
     * Check if the this object equals to object to see
     *
     * @param object The object to see.
     * @type {boolean}
     * @since 1.0
     */
    equals(object) {
        if (Objects_js_1.Objects.isNull(object))
            return false;
        if (object == this)
            return true;
        if (object instanceof ObjectName)
            return __classPrivateFieldGet(this, _mName) == __classPrivateFieldGet(object, _mName);
        return false;
    }
    asType() {
        if (__classPrivateFieldGet(this, _mHandlerType) == null)
            __classPrivateFieldSet(this, _mHandlerType, new HandlerType(__classPrivateFieldGet(this, _mName)));
        return __classPrivateFieldGet(this, _mHandlerType);
    }
    asImport() {
        if (__classPrivateFieldGet(this, _mHandlerImport) == null)
            __classPrivateFieldSet(this, _mHandlerImport, new HandlerImport(__classPrivateFieldGet(this, _mPath)));
        return __classPrivateFieldGet(this, _mHandlerImport);
    }
    asListener() {
        if (__classPrivateFieldGet(this, _mHandlerListener) == null)
            __classPrivateFieldSet(this, _mHandlerListener, new HandlerListener(...__classPrivateFieldGet(this, _mListeners)));
        return __classPrivateFieldGet(this, _mHandlerListener);
    }
    /**
     * Use this to cast this ObjectName object.
     *
     * @param objectNames The objects names to be casted with this ObjectName object.
     * @type {ObjectName}
     * @since 1.0
     */
    cast(...objectNames) {
        __classPrivateFieldSet(this, _mCasts, Arrays_js_1.Arrays.asList(objectNames));
        return this;
    }
    getCasts() {
        return __classPrivateFieldGet(this, _mCasts);
    }
}
exports.ObjectName = ObjectName;
_mPath = new WeakMap(), _mName = new WeakMap(), _mListeners = new WeakMap(), _mHandlerType = new WeakMap(), _mHandlerImport = new WeakMap(), _mHandlerListener = new WeakMap(), _mCasts = new WeakMap();
/**
 * Primitive type object.
 * @type {ObjectName}
 * @since 1.0
 */
ObjectName.OBJECT = ObjectName.get(undefined, "object");
/**
 * Primitive type string.
 * @type {ObjectName}
 * @since 1.0
 */
ObjectName.STRING = ObjectName.get(undefined, "string");
/**
 * Primitive type boolean.
 * @type {ObjectName}
 * @since 1.0
 */
ObjectName.BOOLEAN = ObjectName.get(undefined, "boolean");
/**
 * Primitive type number.
 * @type {ObjectName}
 * @since 1.0
 */
ObjectName.NUMBER = ObjectName.get(undefined, "number");
/**
 * Primitive type void.
 * @type {ObjectName}
 * @since 1.0
 */
ObjectName.VOID = ObjectName.get(undefined, "void");
/**
 * Primitive type any.
 * @type {ObjectName}
 * @since 1.0
 */
ObjectName.ANY = ObjectName.get(undefined, "any");
class HandlerType {
    constructor(name) {
        _name.set(this, void 0);
        __classPrivateFieldSet(this, _name, name);
    }
    getName() {
        return __classPrivateFieldGet(this, _name);
    }
}
_name = new WeakMap();
class HandlerImport {
    constructor(path) {
        _path.set(this, void 0);
        __classPrivateFieldSet(this, _path, path);
    }
    getPath() {
        return __classPrivateFieldGet(this, _path);
    }
}
_path = new WeakMap();
class HandlerListener {
    constructor(...listener) {
        _listener.set(this, void 0);
        __classPrivateFieldSet(this, _listener, listener);
    }
    getListener() {
        return __classPrivateFieldGet(this, _listener);
    }
}
_listener = new WeakMap();
//# sourceMappingURL=ObjectName.js.map